<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:import href="../base.xslt"/>

	<xsl:template match="/root">
	
		 
	
		<xsl:call-template name="two-columns-layout">
			<xsl:with-param name="head">
			
			<script language="javascript">
			
				$(document).ready(function() {
					xprtGetJSON("/test/doItBetter",
					{mthd: "executeJson"},
					function(root) {
						//alert (root.cars[0].car.name);
					});
				});

			</script>
			
			</xsl:with-param>
			<xsl:with-param name="navigation">navigation</xsl:with-param>
			<xsl:with-param name="leftcolumn">leftcolumn</xsl:with-param>
			<xsl:with-param name="maincolumn">
			
				<h2>My Collection</h2>
				
				<xsl:call-template name="text">
					<xsl:with-param name="name">car</xsl:with-param>
				</xsl:call-template>
				
				<xsl:call-template name="select">
					<xsl:with-param name="name">id</xsl:with-param>
					<xsl:with-param name="text">
						<option value="-1">Seleccione...</option>
						<xsl:call-template name="options">
							<xsl:with-param name="collection" select="/root/cars/car"/>
							<xsl:with-param name="selected">id</xsl:with-param>
							<xsl:with-param name="value">id</xsl:with-param>
							<xsl:with-param name="text">name</xsl:with-param>
						</xsl:call-template>
					</xsl:with-param>
				</xsl:call-template>
				
				<table border="0" cellpadding="6" cellspacing="0">
					<tr>
						<th>ID</th>
						<th>Name</th>
						<th>Model</th>
					</tr>

					<xsl:for-each select="cars/car">
						<xsl:element name="tr">
							<xsl:if test="(position() mod 2 = 1)">
								<xsl:attribute name="style">background-color: #DDDDDD;</xsl:attribute>
							</xsl:if>
							<td><xsl:value-of select="id"/></td>
							<td><xsl:value-of select="name"/></td>
							<td><xsl:value-of select="model/name"/></td>
						</xsl:element>
					</xsl:for-each>
				</table>
				
			</xsl:with-param>
			<xsl:with-param name="footer">footer</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
	
	
</xsl:stylesheet>